{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='../../plugin/redrain/template/web/common_nav'}
    {if $method == "flag_main"}
    <div class="panel panel-info">
        <div class="panel-heading">当前数量： {$page_total}</div>
        <div class="panel-body">
            <form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="web" />
                <input type="hidden" name="r" value="redrain.flag.main" />
                <input type="hidden" name="status" value="{$status}">
                <div class="form-group">
                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">红包状态</label>
                    <div class="col-xs-11 col-sm-9 col-md-9">
                        <div class="btn-group">
                            {loop $status_arr $row}
                            <a href="{php echo createWebUrlPlugin('redrain.flag',array('themeid'=>$themeid,'status'=>$row['status'],'id'=>$id));}" class="btn {if $status === $row['status']}btn-primary{else}btn-default{/if}">
                                {$row['title']}
                                <span style="color: #ff0000">{$row['total']}</span>
                            </a>
                            {/loop}
                        </div>

                    </div>
                    {if count($themelist)>1 }
                    <div class="col-xs-12 col-sm-2 col-md-2">
                        <select onchange="submitForm();" class="form-control" name="themeid">
                            {loop $themelist $row}
                            <option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
                            {/loop}
                        </select>
                    </div>
                    {else}
                    <input type="hidden" name="themeid" value="{$themeid}" />
                    {/if}
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">获取时间</label>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        {php echo view_form_field_daterange('createtime', array('start'=>date('Y-m-d H:i:s',$starttime),'end'=>date('Y-m-d H:i:s',$endtime)), true);}
                    </div>

                </div>
                <div class="form-group clearfix">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
                    <div class="col-sm-3 col-xs-3 col-md-3">
                        <input class="form-control" name="search_data" placeholder="输入报名手机号或微信昵称" type="text" value="{$_P['search_data']}">
                    </div>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                    </div>
                    <div class="col-sm-2 col-lg-2 col-md-2 col-xs-2">
                        {if $total<=5000}
                        <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出红包记录EXCEL">
                        {else}
                        <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出红包记录EXCEL(1-5000条)">
                        {/if}
                    </div>
                </div>
            </form>
        </div>
    </div>
    {/if}

    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width: 50px">序号</th>
                        <th style="width: 120px">昵称</th>
                        <th style="width: 120px">姓名/电话</th>
                        <th style="width: 100px">红包金额</th>
                        <th style="width: 100px">红包状态</th>
                        <th style="width: 100px">员工归属</th>
                        <th style="width: 100px">订单状态</th>
                        <th style="width: 120px">创建时间</th>
                        <th style="width: 100px">核销人</th>
                        <th style="width: 120px">核销时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $list $index $item}
                    <tr>
                        <td>{php echo $index+1;}</td>
                        <td>
                            <img src="{php echo tomedia($item['avatar']);}" style="width: 28px;height: 28px;padding: 1px;">
                            <br>
                            {$item['nickname']}
                        </td>
                        <td>{$item['username']}<br/>{$item['mobile']}</td>
                        <td>{$item['title']}</td>
                        <td>
                            {if $item['status']==0}
                            <span class="label label-warning">待领取</span>
                            {elseif $item['status']==3}
                            <span class="label label-default">已使用其他，当前失效</span>
                            {elseif $item['status']==2}
                            <span class="label label-danger">已过期</span>
                            {elseif $item['status']==1}
                            <span class="label label-success">已核销</span>
                            {else}
                            {/if}
                        </td>
                        <td>
                            {$item['workername']}
                        </td>
                        <td>
                            {$item['order_info']}
                        </td>
                        <td>
                            {$item['created_at']}
                        </td>
                        <td>
                            {if $item['status']==1}
                            <a>
                                {$item['workername']}
                                <br>
                                {$item['teamname']}
                                <br>
                                {$item['companyname']}
                                <br>
                                {$item['checked_at']}
                            </a>
                            {/if}
                        </td>
                        <td>
                            {if $item['status']==1}
                            {$item['convert_at']}
                            {/if}
                        </td>

                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

{$pager}
<script type="text/javascript">
    function jump(){
        layer.msg('正在准备下载');
    }
    function submitForm(){
        $("#r").val('redrain.flag.main');
        var form = document.getElementById("myform");
        form.submit();
    }
</script>
